# -*- coding: utf-8 -*-

import matplotlib.pyplot as plt  
import matplotlib.finance as mpf 

from matplotlib.pylab import date2num  


# 对tushare获取到的数据转换成candlestick_ohlc()方法可读取的格式  
def trans_data(hist_data):
    data_list=[]
    for dates,row in hist_data.iterrows():  
        # 将时间转换为数字  
        open,high,close,low = row[:4]  
        datas = (date2num(dates)  ,open,high,low,close)  
        data_list.append(datas)  
    return data_list


def huitu(df,m10=None):
    fig, ax = plt.subplots(facecolor=(0.5, 0.5, 0.5))  
    fig.subplots_adjust(bottom=0.2)  
    mpf.candlestick_ohlc(ax,trans_data(df),width=1.2,colorup='r',colordown='green') 
    ax.plot(m10)

    
    
    
    


